package com.amumu.drama.common.constant;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;

/**
 * @author sunzhuang
 * @date 2024/7/4 14:51
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc 阿里支付相关的静态变量
 */
@Getter
public enum AlipayTradeStatusEnum {

    /**
     * 阿里支付交易状态
     */
    WAIT_BUYER_PAY("WAIT_BUYER_PAY", "交易创建，等待买家付款。"),
    TRADE_CLOSED("TRADE_CLOSED", "未付款交易超时关闭，或支付完成后全额退款。"),
    TRADE_SUCCESS("TRADE_SUCCESS", "交易支付成功。"),
    TRADE_FINISHED("TRADE_FINISHED", "交易结束，不可退款。"),

    ;

    private String code;

    private String desc;

    AlipayTradeStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static final Map<String, AlipayTradeStatusEnum> UNINDEX = Maps.uniqueIndex(Arrays.asList(values()), AlipayTradeStatusEnum::getCode);

    public static AlipayTradeStatusEnum getByCode(String code) {
        return UNINDEX.get(code);
    }
}
